package com.example.git_app_yanshi;


import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.example.git_app_yanshi.R;

import androidx.appcompat.app.AppCompatActivity;

public class register extends AppCompatActivity {

    private EditText accountEt, passwordEt, confirmPasswordEt;
    private Button registerBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_register_yz);
        accountEt = findViewById(R.id.editText2);
        passwordEt = findViewById(R.id.editTextTextPassword2);
        confirmPasswordEt = findViewById(R.id.editTextTextPassword3);
        registerBtn = findViewById(R.id.button2);
        registerBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 获取输入框内容
                String account = accountEt.getText().toString().trim();
                String password = passwordEt.getText().toString().trim();
                String confirmPassword = confirmPasswordEt.getText().toString().trim();
                // 检查密码是否一致
                if (password.equals(confirmPassword)) {
                    // 密码一致，弹出注册成功提示
                    Toast.makeText(register.this, "注册成功,请点击返回并登录", Toast.LENGTH_SHORT).show();
                    // 这里可以添加将用户信息保存到数据库等后续逻辑
                } else {
                    // 密码不一致，弹出提示
                    Toast.makeText(register.this, "两次输入的密码不一致，请重新输入", Toast.LENGTH_SHORT).show();
                }
            }
        });
        Button btnClose = findViewById(R.id.button3);
        btnClose.setOnClickListener(v -> finish());
    }
}